package com.exp.java;

import java.sql.*;

class DbManager {
	
	static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
	static final String DB_URL = "jdbc:mysql://localhost/firstapp";
	static final String USER = "root";
	static final String PASS = "root";

	public ResultSet retrieveData() {
		Connection conn = null;
		Statement stmt = null;
		ResultSet rs = null;

		try {
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection(DB_URL,USER,PASS);
			stmt = conn.createStatement();
			//String sql;
			//sql = "SELECT * FROM EMPLOYEE";
			rs = stmt.executeQuery("SELECT * FROM EMPLOYEE");
			while(rs.next()){
				System.out.println(rs.getInt(1));
			}

		} catch (SQLException se) {
			se.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (conn != null)
					conn.close();
				if (stmt != null)
					stmt.close();
			} catch (SQLException se) {
				se.printStackTrace();

			}
		}
		return rs;
	}

}
